package com.sky.controller.user;

import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/user/category")
@RestController("userCategoryController")
@Slf4j
@Tag(name = "分类管理",description = "分类品管理相关接口")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 根据类型查询所有分类
     * @param type
     * @return
     */
    @GetMapping("/list")
    @Operation(summary = "查询所有分类")
    public Result<List<Category>> getCategoryList(Integer type){
        log.info("查询所有分类:{}",type);
        List<Category> categoryList = categoryService.getByType(type);
        return Result.success(categoryList);
    }
}
